import { createRouter, createWebHistory } from 'vue-router'
// 导入页面组件
import LoginVue from "@/pages/login/index.vue"
import HomeVue from "@/pages/Home/index.vue"
import ChatVue from "@/pages/Chat/index.vue"
import component from 'element-plus/es/components/tree-select/src/tree-select-option.mjs'

const routes = [
  {
    path: '/login',
    name: 'LoginVue',
    component: LoginVue,
    meta: { title: 'AI角色扮演-登录' }
  },
  {
    path: '/',
    name: 'HomeVue',
    component: HomeVue,
    meta: { title: 'AI角色扮演-首页' }
  },
  {
    path:'/chat',
    name:'ChatVue',
    component:ChatVue,
    meta:{title:'AI角色扮演-聊天'}
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 路由守卫，用于设置页面标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
